#include"tree.h"


BTNode* BuyNode(BTDatatype x)
{
	BTNode* node = (BTNode*)malloc(sizeof(BTNode));
	if (node == NULL)
	{
		perror("malloc fail");
		exit(1);
	}
	node->left = node->right = NULL;
	node->data = x;

	return node;
}
BTNode* CreatBinaryTree()
{
	BTNode* nodeA = BuyNode('A');
	BTNode* nodeB = BuyNode('B');
	BTNode* nodeC = BuyNode('C');
	BTNode* nodeD = BuyNode('D');
	BTNode* nodeE = BuyNode('E');
	BTNode* nodeF = BuyNode('F');
	BTNode* nodeG = BuyNode('G');

	nodeA->left = nodeB;
	nodeA->right = nodeC;
	nodeB->left = nodeD;
	nodeB->right = nodeG;
	nodeC->left = nodeE;
	nodeC->right = nodeF;

	return nodeA;
}

void test01()
{
	BTNode* root = CreatBinaryTree();
//	inOrder(root);
	
//	postOrder(root);
//	printf("%d\n", BinaryTreeLeafSize(root));
	//printf("%d\n", BinaryTreeSize(root));
	//printf("%d\n", BinaryTreeSize(root));
	//printf("%d\n", BinaryTreeSize(root));

	//printf("%d\n", BinaryTreeLevalKSize(root,3));
	//printf("%d\n", BinaryTreeLevalKSize(root, 2));
	//printf("%d\n", BinaryTreeLevalKSize(root, 1));
	//printf("%d\n", BinaryTreeLevalKSize(root, 4));

	//printf("%d\n", BinaryTreeDepth(root));
	/*BTNode* x = BinaryTreeFind(root, 'C');
	if(x!=NULL)
	printf("%c\n", x->data);

	BinaryTreeDestory(&root);
	root = NULL;*/

	//LevalOrder(root);
	if (BinaryTreeComplete(root))
		printf("yes");
	else
		printf("no");
}
int main()
{
	test01();
}